import request from '@/utils/request';

// 贷款申请
export function applyLoan(data) {
  return request({
    url: '/api/loan/apply',
    method: 'post',
    data
  });
}

// 查询贷款列表
export function getLoanList(params) {
  return request({
    url: '/api/loan/list',
    method: 'get',
    params
  });
}

// 查询贷款详情
export function getLoanDetail(id) {
  return request({
    url: `/api/loan/${id}`,
    method: 'get'
  });
}

// 查询贷款还款计划
export function getRepaymentPlan(loanId) {
  return request({
    url: `/api/loan/repayment-plan/${loanId}`,
    method: 'get'
  });
}

// 贷款还款
export function repayLoan(data) {
  return request({
    url: '/api/loan/repay',
    method: 'post',
    data
  });
}

// 提前还款试算
export function calculateEarlyRepayment(params) {
  return request({
    url: '/api/loan/early-repayment/calculate',
    method: 'get',
    params
  });
}

// 提前还款
export function earlyRepayment(data) {
  return request({
    url: '/api/loan/early-repayment',
    method: 'post',
    data
  });
}

// 贷款审批（管理员接口）
export function approveLoan(loanId, params) {
  return request({
    url: `/api/loan/approve/${loanId}`,
    method: 'post',
    params
  });
}
